!DOCTYPE html>
<html>
    <head>
        <title>iOSandJs</title>
        <styletype="text/css">
            <script src="commen.js"></script>
            *{
            font-size: 40px;
            }
            </style>
            </head>
    
    <body>
        <script>
<!--            changeTop_del1();-->
        </script>
        <div style="margin-top: 100px">
            
            <h1>Test howtouseobjective-c calljs</h1><br/>
            <div><input type="button" value="call js alert" onclick="callJsAlert()"></div>
            <br/>
            <div><input type="button" value="Call js confirm" onclick="callJsConfirm()"></div><br/>
            </div>
            <br/>
            <div>
                <div><input type="button" value="Call Js prompt " onclick="callJsInput()"></div><br/>
                <div>Click me here: <a href="https://www.baidu.com/">Jump toBaidu</a></div>
            </div>
            
            <script type="text/javascript">
                function changeTop_del() {
                    alert('123123123123123');
                    
                    window.webkit.messageHandlers.AppModel.postMessage({body: '1231231231231231231'});
                }

            </script>
            <br/>
            <divid="SwiftDiv">
                <span id="jsParamFuncSpan" style="color: red; font-size: 50px;"></span>
                    </div>
                    
                    <script type="text/javascript">
                        function callJsAlert() {
                        alert('Objective-C call js to show alert');
                        
                        window.webkit.messageHandlers.AppModel.postMessage({body: 'call js alert in js'});
                        }
                        
                        function callJsConfirm() {
                        if (confirm('confirm', 'Objective-C call js to show confirm')) {
                        document.getElementById('jsParamFuncSpan').innerHTML
                        = 'true';
                        } else {
                        document.getElementById('jsParamFuncSpan').innerHTML
                        = 'false';
                        }
                        
                        // AppModel是我们所注入的对象
                        window.webkit.messageHandlers.AppModel.postMessage({body: 'call js confirm in js'});
                        }
                        
                        function callJsInput() {
                        var response = prompt('Hello', 'Please input your name:');
                        document.getElementById('jsParamFuncSpan').innerHTML = response;
                        
                        // AppModel是我们所注入的对象
                        window.webkit.messageHandlers.AppModel.postMessage({body: response});
                        }
                        </script>
        </body>
</html>
